package jetpack.com.pzl.works;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

//模拟耗时的任务
public class TiredWorker extends Worker {
    final String TAG = "jinx_TiredWorker";

    public TiredWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
        super(context, workerParams);
    }

    @NonNull
    @Override
    public Result doWork() {

        int count = 0;
        while (count <= 100) {
            Log.i(TAG, "Tired ....." + count);
            try {
                Thread.sleep(330);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            count++;
        }
        return Result.success();
    }


}
